import Taro from '@tarojs/taro'
import './app.scss'

class App extends Taro.Component {
  componentWillMount = () => {
    // 展示本地存储能力
    var app = Taro.getApp()
    var logs = Taro.getStorageSync('logs') || []
    logs.unshift(Date.now())
    Taro.setStorageSync('logs', logs)

    const systemInfo = Taro.getSystemInfoSync()
    const { windowHeight, statusBarHeight } = systemInfo

    this.globalData.windowHeight = windowHeight
    // 缓存状态栏高度
    this.globalData.statusBarHeight = statusBarHeight
    // title部分固定高度50
    this.globalData.titleHeight = 43
    // header部分高度
    this.globalData.headerHeight = statusBarHeight + this.globalData.titleHeight
    // 内容部分高度
    this.globalData.contentHeight = windowHeight - this.globalData.headerHeight
    // 去掉状态栏高度，后的高度
    this.globalData.entryHeight = windowHeight - statusBarHeight

    this.$app.globalData = this.globalData
  }
  globalData = {
    userInfo: null
  }
  config = {
    pages: [
      'pages/index/index',
      'pages/tag-detail/index',
      'pages/tag/index',
      'pages/detail/index',
      'pages/me/index',
      'pages/favorite/index',
      // 'pages/scrollView/index', // 测试文章加载页面
    ],
    window: {
      backgroundTextStyle: 'light',
      navigationBarBackgroundColor: '#fff',
      navigationBarTitleText: '',
      navigationBarTextStyle: 'black',
      navigationStyle: 'custom',
      enablePullDownRefresh: false,
      backgroundColor: '#ddd',
    },
    tabBar: {
      color: '#dedede',
      selectedColor: '#fe5a57',
      backgroundColor: '#fff',
      borderStyle: 'white',
      position: 'bottom',
      list: [
        {
          pagePath: 'pages/index/index',
          text: '首页',
          iconPath: './icons/home.png',
          selectedIconPath: './icons/home-selected.png'
        },
        {
          pagePath: 'pages/tag/index',
          text: '标签',
          iconPath: './icons/tag.png',
          selectedIconPath: './icons/tag-selected.png'
        },
        {
          pagePath: 'pages/me/index',
          text: '我',
          iconPath: './icons/user.png',
          selectedIconPath: './icons/user-selected.png'
        },
        // {
        //   pagePath: 'pages/scrollView/index',
        //   text: '测试',
        //   iconPath: './icons/home.png',
        //   selectedIconPath: './icons/home-selected.png'
        // },
      ]
    }
  }

  render() {
    return null
  }
} //app.js

export default App
Taro.render(<App />, document.getElementById('app'))
